﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学运行基础数据 - 培养方案修订 - 添加新课程");

		sql = "SELECT sbj_name, schooling_length 
				FROM t_subject 
				WHERE sbj_id = :sbjId "; 
				
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="sbjId", value=event.getArg("SubID"), cfsqltype="cf_sql_varchar" );
		
		rs_subjectEntity = queryObj.execute( sql=sql ).getResult();

		sql = "SELECT sbj_id, sbj_name, sbj_direction  
				FROM t_subject 
				WHERE sbj_id LIKE :subjectDirs "; 
				
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="subjectDirs", value=event.getArg("SubID")&"_", cfsqltype="cf_sql_varchar" );
		
		rs_subjectDirs = queryObj.execute( sql=sql ).getResult();

		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");

		targetArgs = structNew();
		structInsert(targetArgs, "SubID", event.getArg("SubID"), true);
		structInsert(targetArgs, "Edition", event.getArg("Edition"), true);
		structInsert(targetArgs, "Schema", event.getArg("Schema"), true);
		structInsert(targetArgs, "Dir", event.getArg("Dir"), true);

		event.setArg('Term', "01");

		passArgs = structNew();

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programSchema')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">培养方案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 edit"></i>培养方案修订 - <cfoutput>#rs_subjectEntity.sbj_name#</cfoutput>专业(<cfoutput>#event.getArg("Edition")#</cfoutput>)版
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	
	<ul class="accountSearch">
		<li>
			<div class="clearfix">
				<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('programSchemaWizardCreateDirectionEntity', targetArgs)#</cfoutput>">
					<div class="label">
						<b>课程名称</b>
						<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
					</div>
					<hr/>
					<div class="lable">
						<input class="button1" type="submit" value="搜索课程" />
					</div>
				</form>
			</div>
		</li>
	</ul>
	
	<cfif event.isArgDefined('Keywords') AND len(event.getArg('Keywords'))>
    
    	<cfset sql = "SELECT 
							t_course.cid, t_course.course_name, t_course.course_credit, t_course.period, 
							t_course.period_theory, t_course.period_practice, t_course.period_computer, 
							t_course.period_week, 
							t_institute.institute_short, 
							t_course.course_code 
						FROM 
							t_course  
							INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
						WHERE 
							t_course.abandon = '0' 
							AND 
							(
								  t_course.course_name LIKE :keyword 
								  OR 
								  t_course.course_code LIKE :keyword 
							)
						ORDER BY 
							t_course.course_name ASC " />
                            
		<cfset queryObj = new query( datasource=application.dnsSlave, maxRows=30 ) />
		<cfset queryObj.addParam( name="keyword", value=event.getArg('Keywords')&'%', cfsqltype="cf_sql_varchar" ) />
        
		<cfset rs_courses = queryObj.execute( sql=sql ).getResult() />
	
		<cfif rs_courses.recordCount>
		
		<ul class="senateFirstPage">
			<li>
				<div class="clearfix" id="summary">
					
					<div id="searchProcess" class="tabContentBox hidden_elem">
						
						<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper " method="post" action="<cfoutput>#buildURL('programSchemaWizardDirectionEntityCreateDo')#</cfoutput>">
							
							<input name="Grade" id="Grade" type="hidden" value="<cfoutput>#event.getArg('Edition')#</cfoutput>" />
							
							
							<input name="CourseID" id="CourseID" type="hidden" value="" />
							
							
							<div class="label">
								<b>课程</b>
								<input name="CourseName" id="CourseName" type="text" class="typeTextReadOnly" verification="required" maxlength="30" value="" />
							</div>
							
							<div class="label">
								<b>学分</b>
								<input name="Credit" id="Credit" type="text" class="typeTextReadOnly" verification="double" maxlength="4" value="" />
							</div>
							
							<hr/>
							
							<div class="label">
								<b>授课方向</b>
								<table width="300">
                                    <cfloop query="rs_subjectDirs">
										<tr>
											<td><input name="SubjectID" type="radio" class="typeRadio" value="<cfoutput>#rs_subjectDirs.sbj_id#</cfoutput>" <cfif rs_subjectDirs.sbj_id eq event.getArg("Dir")>checked="checked"</cfif>/><cfoutput>#rs_subjectDirs.sbj_name#</cfoutput></td>
										</tr>
									</cfloop>
								</table>
							</div>
							
							<hr/>
							
							<div class="label">
								<b>课程类别</b>
								<select name="CourseNature">
									<option value="1" selected="selected">公共课</option>
									<option value="2">专业课</option>
									<option value="3">实验课</option>
									<option value="4">实践课</option>
									<option value="5">理论课</option>
								</select>
							</div>
							
							<div class="label">
								<b>是否必修</b>
								<input name="CourseProperty" type="radio" class="typeRadio" value="1" checked="checked"/>必修
								<input name="CourseProperty" type="radio" class="typeRadio" value="2" />限选
							</div>
							
							<hr/>
							
							<div class="label">
								<b>计划开课学期</b>
								<table width="300">
									<cfloop from="1" to="#rs_subjectEntity.schooling_length#" index="termYear">
										<cfset term01 = numberFormat((2 * termYear - 1), '0_') />
										<cfset term02 = numberFormat((2 * termYear), '0_') />
										<cfset termS = 'S' & termYear />
										<tr>
											<td><input name="Term" type="radio" class="typeRadio" value="<cfoutput>#term01#</cfoutput>" <cfif event.getArg('Term') eq term01>checked="checked"</cfif>/><cfoutput>#mathAdvice.convertTermIdxToChinese(term01)#</cfoutput></td>
											<td><input name="Term" type="radio" class="typeRadio" value="<cfoutput>#term02#</cfoutput>" <cfif event.getArg('Term') eq term02>checked="checked"</cfif>/><cfoutput>#mathAdvice.convertTermIdxToChinese(term02)#</cfoutput></td>
											<td><cfif termYear lt 4><input name="Term" type="radio" class="typeRadio" value="<cfoutput>#termS#</cfoutput>" <cfif event.getArg('Term') eq termS>checked="checked"</cfif>/><cfoutput>#mathAdvice.convertTermIdxToChinese(termS)#</cfoutput></cfif></td>
										</tr>
									</cfloop>
								</table>
							</div>
							
							<hr/>
							
							<div class="lable">
								<input class="button" type="submit" value="添加新课程" />
								<input id="formReset" class="button" type="reset" value="返回" />
							</div>
							
						</form>
						
					</div>
					
					<div id="searchResult" class="tabContentBox">
						
						<cfset row = 0 />
						<table id="courseList" class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="50" >任课单位</td>
									<td width="80">课程号</td>
									<td>课程</td>
									<td width="24" align="center">学分</td>
									<td width="36" align="center">总学时</td>
									<td width="24" align="center">理论</td>
									<td width="24" align="center">实践</td>
									<td width="24" align="center">上机</td>
									<td width="36" align="center">周学时</td>
								</tr>
							</thead>
							<tbody>
								<cfloop query="rs_courses">
									<cfset row ++ />
									<tr class="clickRows" rowid="<cfoutput>#rs_courses.cid#</cfoutput>">
										<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
										<td><cfoutput>#rs_courses.institute_short#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_courses.course_code#</cfoutput></span></td>
										<td id="courseName<cfoutput>#rs_courses.cid#</cfoutput>"><cfoutput>#rs_courses.course_name#</cfoutput></td>
										<td id="courseCredit<cfoutput>#rs_courses.cid#</cfoutput>"><span class="numeric"><cfoutput>#numberFormat(rs_courses.course_credit, "0.0")#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_courses.period#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_theory#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_practice#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_computer#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_week#</cfoutput></span></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							$(document).ready(function() {
								
								$("#courseList tr.clickRows").click(function(){
									
									var cid = $(this).attr("rowid");
									var cname = $("#courseName" + cid).text();
									var ccredit = $("#courseCredit" + cid).text();
									
									
									/* passArgs to FORM */
									
									$("#CourseID").val(cid);
									$("#CourseName").val(cname);
									$("#Credit").val(ccredit);
									
									$("#searchProcess").removeClass("hidden_elem");
									$("#searchResult").addClass("hidden_elem");
									
								});
								
								$("#formReset").click(function(){
								
									$("#searchResult").removeClass("hidden_elem");
									$("#searchProcess").addClass("hidden_elem");
								
								});
								
								
							});
							// -->
							//]]>
						</script>
						
					</div>
				</div>
			</li>
		</ul>
		
		</cfif>


	</cfif>
	
</div>
				
